<?php
/** Cms_Resource_Supplier_Item */
if (!class_exists('Cms_Resource_Supplier_Item')) {
    require_once dirname(__FILE__) . '/Supplier/Item.php';
}

/**
 * Cms_Resource_Supplier
 *
 * @category   Cms
 * @package    Cms_Model_Resource
 */
class Cms_Resource_Supplier extends BIS_Model_Resource_Db_Table_Abstract implements Cms_Resource_Supplier_Interface
{
    protected $_name = 'supplier';
    protected $_primary = 'supplierId';
    protected $_rowClass = 'Cms_Resource_Supplier_Item';

    public function getSupplierById($id)
    {
        return $this->find($id)->current();
    }

    public function getSuppliers($data= array())
    {
        
        $select = $this->select();

        if (isset($data['order'])) {
            $select->order($data['order']);
        }

	if (isset($data['page'])) {
		$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
		$paginator = new Zend_Paginator($adapter);
		$paginator->setItemCountPerPage($data['limit'])
	          	  ->setCurrentPageNumber((int) $data['page']);
		return $paginator;
	}
        
        return $this->fetchAll($select);

    }
   
}